﻿#region Imports
using System;
using System.Globalization;
using System.Windows.Data;
#endregion

namespace OneStopProgrammingMatrix.Converters
{
    public class UIOffsetConverter : IValueConverter
    {
        #region IValueConverter implementation
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            double offset = GetOffset(parameter);
            return (double)value - offset;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            double offset = GetOffset(parameter);
            return (double)value + offset; // temp logic
        }
        #endregion IValueConverter implementation

        #region Methods
        private double GetOffset(object parameter)
        {
            double offset = 30;
            try { offset = (double)parameter; }
            catch (Exception) { }

            return offset;
        }
        #endregion Methods
    }
}
